package com.dbz.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dbz.entity.ShenPi;
import com.dbz.service.ShenPiService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/shenpi/")
public class ShenPiController {
@Resource
private ShenPiService shenPiService;


@RequestMapping("selectShenpiPage")
public Map selectpageshenpi(Integer page,Integer rows){
    Map<String,Object> map=new HashMap<>();
    QueryWrapper<ShenPi> queryWrapper=new QueryWrapper<ShenPi>();
    IPage<ShenPi> page1=new Page<ShenPi>(page,rows);
    IPage iPage=shenPiService.selectPage(page1,queryWrapper);
    map.put("rows", iPage.getRecords());
    map.put("total",iPage.getTotal());
    return  map;
}






@RequestMapping("insertshenpiAll")
public int insertshenpiAll(@RequestParam String data){
    String list=data;
    List<Object> array=JSON.parseArray(list);
    shenPiService.insertshenpi(array);
    return 1;
}

@RequestMapping("shenPiList")
public List<ShenPi> shenPiList(){

    return shenPiService.shenpilistdt();
}


@RequestMapping("updateshenpistate")
    public int updateshenpistate(String spid,String username){
    shenPiService.updateshenpi(spid,username);
    return 1;
}


    @RequestMapping("noupdateshenpistate")
    public int noupdateshenpistate(String spid,String username){
        shenPiService.noupdateshenpi(spid,username);
        return 1;
    }
}